package com.smartlink.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.smartlink.pojo.Clazz;

public class ClazzDao {
	private SessionFactory sessionFactory;
	private Session session;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public Session getSession() {
		this.session = sessionFactory.getCurrentSession();
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	public List<Clazz> getList() {
		String hql = "FROM Clazz";
		List<Clazz> list = getSession().createQuery(hql).list();
		return list;
	}

	public Clazz getClazzById(int id) {
		Clazz clazz = (Clazz) getSession().get(Clazz.class, id);
		return clazz;
	}

}
